<?php
function makeSalt($password, $salt){
	return md5(md5($password).$salt);
}
function randomString($length = 5) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $randomString;
}
function cleanValue($val){
	if ($val == "") return "";
	$val = str_replace( "&#032;", " ", $val );
	$val = str_replace( chr(0xCA), "", $val );  //Remove sneaky spaces
	$val = str_replace( "'", "&#39;", $val ); // IMPORTANT: It helps to increase sql query safety.
	// Ensure unicode chars are OK
	$val = preg_replace("/&amp;#([0-9]+);/s", "&#\\1;", $val );
	// Strip slashes if not already done so.
	if ( get_magic_quotes_gpc() ){
		$val = stripslashes($val);
	}
	// Swop user inputted backslashes
	return $val;
}